package com.woniu.smart.service.impl;

import com.woniu.smart.entity.SysAdmin;
import com.woniu.smart.mapper.SysAdminMapper;
import com.woniu.smart.service.SysAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: TODO
 * @Author: WangHeng
 * @Date: 2022/10/19 19:40
 */
@Service
public class SysAdminServiceImpl implements SysAdminService {
    @Autowired
    private SysAdminMapper sysAdminMapper;

    @Override
    public List<SysAdmin> selectByAll() {
        return sysAdminMapper.selectByAll();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(SysAdmin record) {
        return 0;
    }

    /**
     * @Description 注册用户
     * @Para a
     * @Retun a
     * @Author WangMr
     * @Date Create by 2022/11/2 09:58
     */
    @Override
    public int insertSelective(SysAdmin record) {
        SysAdmin admin = sysAdminMapper.login(record.getEmpTel());
        if (admin == null) {
            return sysAdminMapper.insertSelective(record);
        }
        return -1;
    }

    /**
     * 根据园区员工姓名查找员工id
     *
     * @param empName
     * @return
     */
    @Override
    public int selectByEmpName(String empName) {
        return sysAdminMapper.selectByEmpName(empName);
    }

    @Override
    public SysAdmin selectEmpTelByEmpName(String EmpName) {
        return sysAdminMapper.selectEmpTelByEmpName(EmpName);
    }

    @Override
    public SysAdmin selectByPrimaryKey(Long id) {
        return sysAdminMapper.selectByPrimaryKey(id);
    }

    @Override
    /**
     * @Description 安全框架的登陆
     * @Param [java.lang.String]
     * @Return com.woniu.smart.entity.SysAdmin
     * @Author WangMr
     * @Date Create by 2022/10/28 10:46
     */
    public SysAdmin login(String empTel) {
        return sysAdminMapper.login(empTel);
    }

    @Override
    public int updateByPrimaryKeySelective(SysAdmin record) {

        return sysAdminMapper.updateByPrimaryKeySelective(record);

    }

    @Override
    public int updateByPrimaryKey(SysAdmin record) {
        return 0;
    }
}
